package com.xzx.protobuf;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.concurrent.EventExecutorGroup;
import lombok.extern.slf4j.Slf4j;

/**
 *
 * @author xinzhixuan
 * @version 1.0
 * @date 2025/11/7 11:19
 */
@Slf4j
public class PBClientHandler extends SimpleChannelInboundHandler<StudentPB.Student> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, StudentPB.Student msg) throws Exception {

    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        ctx.writeAndFlush(StudentPB.Student.newBuilder().setId(1).setName("xinzhixuan").setAge(18).build());
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        log.error("exceptionCaught", cause);
    }
}
